"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".

Replace these with more appropriate tests for your application.
"""
from django.db import IntegrityError
from django.test import TestCase
from models import *

#class SimpleTest(TestCase):
#    def test_basic_addition(self):
#        """
#        Tests that 1 + 1 always equals 2.
#        """
#        self.failUnlessEqual(1 + 1, 2)
#
#__test__ = {"doctest": """
#Another way to test that 1 + 1 is equal to 2.
#
#>>> 1 + 1 == 2
#True
#"""}

#### TESTING DATA ####



import random
def setup():
    jayferd = Profile.create(
        username='jayferd',
        password='password',
        email='me@domain.com',
        role='admin',
        name='Jay Adkisson'
    )
    jayferd.save()
    try:
        Course(instructor=jayferd,slug='math1A',title="Intro Calculus").save()
    except IntegrityError:
        pass
    
    bharvey = Profile.create(
        username='bharvey',
        password='password',
        email='bharvey@domain.com',
        role='instructor',
        name='Brian Harvey'
    )
    bharvey.save()
    try:
        Course(instructor=bharvey,slug='cs61A',title="Intro to Programming Languages").save()
    except IntegrityError:
        pass
    try:
        Course(instructor=bharvey,slug='cs164',title="Programming Languages and Compilers").save()
    except IntegrityError:
        pass
    
    kellen = Profile.create(
        username='kellen',
        password='password',
        email='kajitox@gmail.com',
        role='student',
        name='Kellen Freeman',
    )
    kellen.save()
    
    Course.getByNames(instructor='bharvey',name='cs61A').addMember(kellen,'instructor')
    Course.getByNames(instructor='jayferd',name='math1a').addMember(bharvey)
